package com.ruoyi.system.api.interceptor;

import com.ruoyi.common.core.utils.HMACSHA256;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import org.springframework.beans.factory.annotation.Value;

public class RemoteFileInterceptor implements RequestInterceptor {
    @Value("${file.appid}")
    private String appid;
    @Value("${file.secret}")
    private String secret;

    @Override
    public void apply(RequestTemplate requestTemplate) {
        long ts = System.currentTimeMillis() / 1000;
        String sign = HMACSHA256.sign(appid + "," + ts, secret);
        requestTemplate.uri("/"+appid+"/"+ts+"/"+sign,true);
    }

}
